<?php

namespace backend\models;

use Yii;
//use yii\base\Model;
use common\models\Menu;
use yii\data\ActiveDataProvider;

/**
 * This is the model class for table "{{%menu}}".
 *
 * @property string $id
 * @property string $title
 * @property string $url
 * @property string $sort
 * @property string $create_time
 * @property string $pid
 * @property string $group
 * @property integer $status
 */
class MenuSearch extends Menu
{

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['create_time', 'status'], 'integer'],
            [['title'], 'string', 'max' => 50]
        ];
    }


	
	public function search($params){
		$query = Menu::find()->where('status=1');

		$dataProvider = new ActiveDataProvider([
			'query' => $query,
			'pagination' => [
				'pagesize' => '10',
			]
		]);

		// 加载搜索表单数据并验证
		if (!($this->load($params) && $this->validate())) {
			return $dataProvider;
		}

		// 通过添加过滤器来调整查询语句
		$query->andFilterWhere(['id' => $this->id]);
		$query->andFilterWhere(['like', 'title', $this->title])
			->andFilterWhere(['like', 'create_time', $this->create_time]);

		return $dataProvider;
	}

}
